home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / misc / emu / Apex-src.lha / APEX.DOC < prev    next >
Text File  |  2000-05-16  |  92KB  |  2,260 lines

  1. 
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. =============================================================
  12. |                                                           |
  13. |        #         # # #        # # # #    #         #      |
  14. |      #   #       #     #      #            #     #        |
  15. |    #       #     #      #     #             #   #         |
  16. |   #         #    #       #    #              # #          |
  17. |   #         #    #     #      #              # #          |
  18. |   # # # # # #    # # #        # # # #        # #          |
  19. |   #         #    #            #            #     #        |
  20. |   #         #    #            # # # #    #         #      |
  21. |                                                           |
  22. |                 VERSION 1.0   MARCH 1980                  |
  23. =============================================================
  24.          Copyright P.J.R. Boyle 1980.
  25.  
  26.  
  27.             CONTENTS
  28.             ========
  29.  
  30. INTRODUCTION............................................... 1
  31. BOOTING APEX............................................... 4
  32.     Booting on non-standard systems.................... 4
  33. DISK ORGANIZATION.......................................... 5
  34.     Write locking disks................................ 5
  35.     Unit allocations................................... 5
  36. UNIT ORGANIZATION.......................................... 7
  37.     System units....................................... 7
  38. FORMATTING DISKS........................................... 7
  39. FILES IN APEX.............................................. 8
  40.     Types of files..................................... 8
  41.     File specifications................................ 8
  42.     Illegal file names................................. 9
  43.     Standard extensions................................ 9
  44.     Using files........................................10
  45.     Opening and closing files..........................10
  46.     Backup files.......................................11
  47.     System files.......................................12
  48. DEFAULTS...................................................13
  49.     General default structure..........................14
  50. SWAPPING...................................................16
  51.     When you swap and when you don't...................16
  52.     Running without swapping...........................17
  53. DATES......................................................18
  54. ERRORS.....................................................19
  55. APEX SYNTAX................................................20
  56. SWITCHES IN APEX...........................................21
  57.     Command line switches..............................21
  58.     System wide switches...............................21
  59.     Save file switches.................................21
  60. MEMORY USE.................................................23
  61.     Other memory use...................................24
  62. DEVICE HANDLERS............................................25
  63.     Handler entry points...............................26
  64.     Accessing device handlers..........................27
  65.     Inserting device handlers..........................27
  66.     Standard device handlers...........................27
  67. THE CONSOLE DEVICE.........................................29
  68. APEX SYSTEM PAGE...........................................31
  69.     Start and exit vectors.............................31
  70.     Saved image parameters.............................32
  71.     Program space parameters...........................32
  72.     I2L parameters.....................................32
  73.     Buffers............................................32
  74.     Other program specific globals.....................33
  75.     Input and output file parameters...................34
  76.     Unit driver information block......................34
  77.     Device handler table...............................34
  78.     Other system dependant globals.....................34
  79. APEX RESIDENT SYSTEM VECTORS...............................36
  80.     Apex entry points..................................36
  81.     Apex resident system functions.....................36
  82. COMMANDS...................................................38
  83.     Run................................................38
  84.     Zero...............................................39
  85.     Make...............................................39
  86.     Directory..........................................40
  87.     Delete.............................................41
  88.     Save...............................................41
  89.     Open...............................................42
  90.     Initialize.........................................44
  91.     Start..............................................44
  92.     Swap...............................................45
  93.     Get................................................45
  94.     Rename.............................................45
  95.     Close..............................................45
  96.     List...............................................46
  97.     Title..............................................46
  98.     Dfile..............................................46
  99.     No and Do..........................................47
  100.     Date...............................................47
  101.     Bdir...............................................47
  102.     System.............................................48
  103.     Size...............................................48
  104.     New................................................49
  105. APEX STANDARD UTILITIES....................................50
  106.     Set................................................50
  107.     Exch...............................................50
  108.     Squash.............................................51
  109.     Copy...............................................51
  110.     Booter.............................................51
  111.     Maker..............................................51
  112.     Load...............................................52
  113.     Dupdsk.............................................53
  114. COMMAND SUMMARY............................................54
  115.  
  116.             PREFACE
  117.             =======
  118.  
  119. Apex is a powerful and general operating system. The ways in
  120. which it can be used are almost infinite. You will need some
  121. patience at first since Apex is not a simple application program
  122. which can lead you by the hand. In some configurations Apex will
  123. be used with a high level language such as XPL0, which will hide
  124. the messy details of Apex for you. However the basic Apex
  125. package is intended for assembly language programmers and that
  126. is the focus of this document.
  127.  
  128. Any documentation of such a system must neccessarily be rather
  129. terse and self referent. This manual supplies the essential
  130. information you will need to use Apex. A lot of this information
  131. is not critical when Apex is used in the simplest way but is
  132. essential for more complex operations. Thus this manual will
  133. need several readings. First to get the overview, then to get
  134. the basic information you need to begin to use Apex and, later,
  135. to extract the detail you need for some specific task.
  136.  
  137. Eventually you will need to read and understand the listings
  138. provided with this manual in order to use the full potential of
  139. Apex. Note that these listings are supplied for pedagogic
  140. purposes only. The specific code you recieve with Apex may be a
  141. later revision or may be for a different system configuration.
  142. The principles will remain however.
  143.  
  144.  
  145.         INTRODUCTION
  146.         ============
  147. 
  148.  
  149. Welcome to Apex. You now have at your disposal an entirely new
  150. organization of your Apple II which will make many new things
  151. possible. Apex will make your Apple perform in ways which you
  152. have previously only found in much larger machines. Best of all,
  153. Apex will do this without tying up large chunks of memory,
  154. without limiting the things you can do with your Apple, and
  155. without a continual machine-time overhead.
  156.  
  157. Apex is a programmer's operating system. It is designed to
  158. provide a powerful program development environment while
  159. retaining a general purpose overall structure that will be
  160. compatible with most specific application tasks.
  161.  
  162. Apex has a multi-level structure. Some of Apex is always in
  163. memory while other parts of it will share memory with your
  164. program in the same way some large machines implement "virtual"
  165. memory; that is by swapping portions of memory to and from the
  166. system disk.
  167.  
  168. Apex has been designed for simple program interface. In
  169. principle no program need know anything about Apex unless it
  170. wants to use Apex facilities. In this way, almost any program
  171. may be run under Apex. The exception, of course, is a program
  172. that was written to use the facilities of some other operating
  173. system, such as Apple DOS.
  174.  
  175. The most fundamental service Apex provides is the organization
  176. and maintenance of your disk space. It does this by partitioning
  177. the disk space into "units" and "files".
  178.  
  179. Units are large, fixed areas of disk storage space which are
  180. allocated in part in correspondence with external constraints,
  181. and in part in accordance with convenience factors. On small
  182. systems, a unit will typically correspond to a physical floppy
  183. disk.
  184.  
  185. Files, on the other hand, are sections of a unit which are
  186. variable in size and have names. Apex provides you and your
  187. programs with access to files by name and to units by their
  188. number.
  189.  
  190. Another major service Apex provides is a modular and global
  191. mechanism for accessing your peripheral devices, such as
  192. terminals, printers etc. Apex contains a set of modular programs
  193. called device "handlers". Each device has a handler, which is
  194. the only piece of code which needs to know about the specific
  195. details of the device. This means that programs under Apex need
  196. not know about the specific details of the printer you have etc.
  197. Normally your standard version of Apex will contain handlers for
  198. your periperal devices as well as for the Apple keyboard and
  199. screen (together known as the "console" device), and for the
  200. disks you have. 
  201.  
  202. A word about languages is in order here. Unlike Apple DOS or
  203. Apple Pascal, Apex is not imbedded into any one langauge.
  204. Instead, it provides a general overall structure into which any
  205. language can be placed. This has the important advantage that
  206. you don't have to re-learn your machine every time you change
  207. languages. The root language of Apex is, of course, Assembly
  208. language. Other languages have been implemented under Apex,
  209. notably XPL0 and FOCAL. They are probably available from the
  210. same source you obtained Apex. Apple's BASICs can be run under
  211. Apex if you insist, but of course those functions which are DOS
  212. related will not work. UCSD Pascal is its own operating system
  213. and will not run under anything.
  214.  
  215. In every software project there are certain design decisions
  216. which must be made. In Apex some of these decisions have been
  217. made differently from most other operating systems. Loosely
  218. speaking, the reason for this is that Apex has a different
  219. focus, and so the priorities come out different.
  220.  
  221. For one thing Apex uses contiguous files. That is, files on an
  222. Apex disk reside in sequential block numbers. This makes
  223. multi-block disk transfers much faster. Apex can load a program
  224. into memory, or a source file into an editor, at speeds that are
  225. impossible with the linked block structure used in Apple DOS.
  226. The cost is that in Apex files must be competely re-written when
  227. they are modified. Copying a file when you modify it is a good
  228. idea anyway, since this makes the process non-fatal in case of
  229. disk errors.
  230.  
  231. For another thing, Apex has a very small resident portion. The
  232. fundamental advantage of this is obvious: You have more user
  233. memory. An un-obvious advantage of this arrangement is that,
  234. since the basic structure of Apex does not define the run-time
  235. environment, Apex can support almost any type of task. It is
  236. possible to build a foreground-background, real-time or
  237. data-base management environment for your programs within the
  238. same basic structure. The penalty is that the run-time code your
  239. programs need does not come as a basic part of Apex. It must be
  240. loaded with each program, either as a separate system module, or
  241. as a part of the program itself.
  242.  
  243. Another tradeoff exists in the area of ease of learning versus
  244. the amount of typing you have to do. Apex is intentionally
  245. cryptic on input and verbose on output. This can a little
  246. confusing at first, but soon you will become very familiar with
  247. it, and the cryptic input will greatly speed your work.
  248.  
  249. A related matter is the issue of protections. In Apex many
  250. protections are built in, such as backup files, backup direc-
  251. tories, read-after-write options, and volume number checks.
  252. However you are the boss, and its your system, so Apex will
  253. allow you to do anything if you insist, no matter how fatal the
  254. operation may appear to be. 
  255.  
  256.             BOOTING APEX
  257. 
  258.  
  259. If you have a standard Apple II or Apple II+ with a standard
  260. Apple II mini disk drive, the Apex system disk you received with
  261. this package should boot, in the same way DOS boots, on the disk
  262. you have connected as drive 1 on slot 6.
  263.  
  264. The first things you will want to do upon booting Apex for the
  265. first time are:
  266.     1)  Study this manual until you have a good idea of what
  267.         Apex is and how it works. Otherwise there is no
  268.         chance that you will succeed in using it.
  269.     2)  "Permit" your disk drives - see the section on unit
  270.         allocations, and the BOOTER utility.
  271.     3)  Make some working disks from the master disk. You
  272.         will use the MAKER and DUPDSK, EXCH or COPY
  273.         utilities. 
  274.  
  275.  
  276. BOOTING ON NON-STANDARD SYSTEMS
  277. 
  278. The bootstrap on the standard master system disk assumes that
  279. the standard Apple bootstrap procedure will work on your
  280. machine. It may not if you have a different bootstrap ROM on
  281. your disk controller (such as if you have the language card) or
  282. if you have a different type of disk drive. In this case you
  283. need a special bootstrap. If one is not available you must boot
  284. the other disk you received, which is an almost standard Apple
  285. DOS disk. On this disk you will find a "binary" file called
  286. APEXBOOT. You must contrive a method to BRUN this file. It loads
  287. into memory at address $3000 and is $800 bytes long.
  288.  
  289. When APEXBOOT is started it prompts you for an Apex disk and
  290. loads Apex from that disk. APEXBOOT does not itself contain
  291. any of the code for Apex. It reads this information from the
  292. Apex system disk in the same way that the normal bootstrap
  293. process would have read it. In this way the Apex bootstrap
  294. maintenance programs still apply. 
  295.  
  296.  
  297.         DISK ORGANIZATION
  298.         =================
  299. 
  300.  
  301. The track, sector, slot, and drive organization of normal Apple
  302. disks is not used in Apex because it is not general enough.
  303.  
  304. Instead, disk storage is organized into blocks, files and units.
  305. These are translated into the appropriate physical entities, for
  306. the specific disk drive in question, by the disk "driver" within
  307. the Apex resident code. The standard Apex system has a driver
  308. which supports the standard Apple 5" disks as well as 8" single
  309. density disks using a controller made by Sorrento Valley
  310. Associates. Drivers for other disks can replace the standard
  311. driver.
  312.  
  313. All of your disk space is ultimately organized into blocks of
  314. 256 bytes each. A unit is manipulated as a fixed sequence of
  315. applicable block numbers. Block numbers begin at zero and go up
  316. in sequence to the size of the unit minus one.
  317.  
  318. WRITE LOCKING DISKS
  319. 
  320. Apex is continually accessing the disks. Thus, write-locking
  321. disks will stop you from doing almost anything. However, it is
  322. possible to run, read, or copy files from a write-locked disk.
  323.  
  324. UNIT ALLOCATIONS
  325. 
  326. In the standard Apex configuration, there are eight possible
  327. units, numbered 0 through 7. These units are assigned to
  328. physical disks through tables in the disk driver code. There is
  329. a default setting of these tables that exists in the driver as
  330. distributed. The resulting assignments are listed in the table
  331. below. In addition to the disk driver tables, there is a
  332. "permit" byte in the system page which tells Apex which units
  333. are extant on the current system. If the standard setting of the
  334. tables includes the drives you have, then all that is neccessary
  335. in order to enable or disable your drives, is to change the
  336. permit byte at $BF51. When you change this byte, or the driver
  337. tables, you can make the change permanent with the program
  338. BOOTER. In the permit byte, each bit corresponds to a possible
  339. unit. Bit 0, the least significant bit, enables unit 0, bit 1
  340. enables unit 1 etc.
  341.  
  342. Note that unit 0 has a special significance. It is the unit on
  343. which the distributed Apex disk will boot. It is also the unit
  344. to which Apex will return if an error should occur while
  345. accessing the current system unit.
  346.  
  347. ===============================================================
  348. UNIT #        SLOT#    DRIVE#    PERMIT BIT#    TYPE
  349. ------        -----    ------       -----    ----
  350. 0        6    1         0        Apple disk II
  351. 1        6    2         1        Apple disk II
  352. 2        5    1         2        Apple disk II
  353. 3        5    2         3        Apple disk II
  354. 4        7    1         4        SVA 8" disk.
  355. 5        7    2         5        SVA 8" disk.
  356. 6        7    3         6        SVA 8" disk.
  357. 7        7    4         7        SVA 8" disk.
  358.  
  359.         STANDARD UNIT ASSIGNMENT TABLE
  360. ===============================================================
  361.  
  362.  
  363.  
  364.         UNIT ORGANIZATION
  365. 
  366. A unit has some blocks (0-8) reserved for bootup code etc.
  367. Following these blocks is a unit directory (9-12) which
  368. describes the files on the unit. On most units, a backup
  369. directory follows the main directory (13-16). The rest of the
  370. unit (17-) is available for file storage. A bootable disk
  371. requires that the first few blocks of file space (17-25) contain the
  372. resident code in a special system file.
  373.  
  374. A standard Apple mini-disk has 455 blocks on it of which 438 are
  375. available for files.
  376.  
  377. SYSTEM UNITS
  378. 
  379. In Apex, a unit may be either a system unit or not. At all times
  380. there should be at least one valid system unit on line, so, if
  381. you have only one disk drive, most of your disks will be system
  382. units. If you have more than one disk drive, you will probably
  383. have only one system unit on line at a time. A system unit is
  384. distinguished from a non-system unit by the existence of the
  385. files with the SYS extension. These files can be deleted from a
  386. system unit to make the unit into a non-system unit.
  387.  
  388.  
  389.         FORMATTING DISKS
  390. 
  391. Apex disks must, in general, be formatted before they can be
  392. used. This process is a property of the individual disk and
  393. drive you have, so Apex leaves this process as an external
  394. function to be completed by the process described by the disk
  395. drive supplier.
  396.  
  397. The DOS disk you received with Apex has one important detail
  398. which is different from most DOS disks. The DOS "INIT" process,
  399. which formats an Apple II 5" disk, when performed from this
  400. disk, will format a disk with a special sectoring which allows
  401. Apex to run at the maximum speed.
  402.  
  403. Note that the Apple DOS "INIT" process is something unique to
  404. the Apple mini-floppies. It has nothing to do with other disks,
  405. the Apex INIT command, or to the Apex MAKER process which must
  406. be performed separately.
  407.  
  408.         FILES IN APEX
  409.         =============
  410.  
  411.  
  412. TYPES OF FILES
  413. 
  414.  
  415. At this time, there are three main types of files handled by
  416. APEX. They are system files, save files, and text files.
  417.  
  418. System files contain the Apex system itself and have a unique
  419. format determined by the operating needs of Apex.
  420.  
  421. A save file is a memory image of an executable program. The
  422. program is saved on a unit along with run-time information, such
  423.  
  424. as starting address, exit address, error address, and default
  425. information.
  426.  
  427. A text file is a serial sequence of ASCII characters. The file
  428. can be composed of any ASCII text characters except Control-Z
  429. ($1A). Control-Z is used as an end-of-file mark.
  430.  
  431. FILE SPECIFICATIONS
  432. 
  433. When written out in full, an Apex file specification consists of
  434. a unit number, a file name, and a file extension. For example:
  435.  
  436.     2:NICENAME.TYP
  437.       .     .        .
  438.     .       .          .
  439. unit    file name    extension
  440.  
  441. The legal partial file specifications can be determined from the
  442. syntax diagrams. In many cases a file specification can be
  443. abbreviated to only one of the three parts, or even to just the
  444. colon character. A number alone, with no colon, will be taken as
  445. a unit specification, not a file specification, whenever both
  446. options are possibilities.
  447.  
  448. The unit number determines the unit which has the file, the name
  449. is an arbitrary name you assign (except for SYS files), and the
  450. extension is a file type descriptor.
  451.  
  452. In cases where a file specification is intended to specify more
  453. than one file, such as in copy or delete operations, a "wild" or
  454. "fuzzy" file specification can be used. Any character in the
  455. name or extension part can be replaced by a question mark
  456. character which will match any character in that position. The
  457. entire name or extension part can be made fuzzy by substituting
  458. an asterisk for that part of the specification. Thus "*.*" means
  459. all files, while "*.X??" means all files whose extension begins
  460. with the letter X.
  461.  
  462. ILLEGAL FILE NAMES
  463. 
  464. Apex file names can be up to eight characters long.  The first
  465. character may not be a digit.
  466.  
  467. You are prevented from creating files whose names contain the
  468. slash, asterisk or question-mark characters. Also you may not
  469. create files with the extension BAK.
  470.  
  471. STANDARD EXTENSIONS
  472. 
  473. File name extensions are used to distinguish the different forms
  474. of the same information. For example the same program can exist
  475. as a source file (P65), a backup source file (BAK), an assembled
  476. binary file (BIN), and an executable image (SAV).
  477.  
  478. The assignment of file extensions is up to you. You may freely
  479. invent and use extensions at your whim. However, there are
  480. certain special extensions and certain conventional extensions
  481. which will occur in the defaulting process. The special
  482. extensions are SYS and BAK. The basic conventional extensions
  483. are SAV, P65, and BIN. Depending upon the software you are
  484. running under Apex you may come across other extensions like
  485. XPL, I2L, FCL, LST, BAS, TMP, or DAT.
  486.  
  487. The special extensions are:
  488.  
  489. SYS    These are special files which exist on a system unit
  490.     and have special properties. See later (pg. 12).
  491.  
  492. BAK    These are files which contain a previous revision of
  493.     a text or data file.
  494.  
  495. Some conventional extensions are:
  496.  
  497. SAV    These are files which contain a special form of
  498.     memory image which is directly executable by a run
  499.     command.
  500.  
  501. P65    These are Assembly language source files.
  502.  
  503. BIN    These are the assembler output and loader input files.
  504.  
  505. USING FILES
  506. 
  507. ASCII files generally contain information that is to be
  508. processed in one way or another. The information is usually
  509. processed by a program which exists in a SAV File.
  510.  
  511. ==========      ===========      ==========
  512. ! output !<<<<<<!  pro-   !<<<<<<! input  !
  513. !  file  !      !  gram   !      !  file  !
  514. ==========      ===========      ==========
  515.  
  516. As the information is processed, it passes from the input file
  517. through the program to the output file.
  518.  
  519. The input file can be any file that exists on a unit. Since the
  520. information is read from the input file, it must already exist
  521. on some unit. The program can be any program that processes
  522. information and has been saved as a SAV file. The output file is
  523. a vacant area on the designated output unit that is set aside by
  524. the operating system. The vacant space is filled by the freshly
  525. processed information. It is not neccessary for the program to
  526. have both an input and an output file. Depending upon the nature
  527. of the information processing, the program may require only an
  528. input file, only an output file, or many files.
  529.  
  530. OPENING AND CLOSING FILES
  531. 
  532. The process of setting up input and output files is called
  533. "OPENING" the files. The Apex run and OPEN commands provide a
  534. simple means for opening the basic input and output file
  535. required by many programs. As in:
  536.  
  537.     ASM FROG
  538. or
  539.     OPEN PIG<DOG
  540.  
  541. The system resident function KSCAN can be used to find other
  542. files on a unit (pg. 37).
  543.  
  544. These files are "setup" by Apex and the information about them
  545. is placed in the input and output file descriptors in the system
  546. page. Programs and handlers that need to use the files can
  547. retrieve this information and use it to control their access to
  548. the disks.
  549.  
  550. A file setup by Apex will have a status byte equal to one. If no
  551. file was setup by Apex the associated file descriptor block will
  552. have a status of zero (pg.34).
  553.  
  554. Initially Apex will assign an output file to the largest
  555. remaining empty space on the designated unit. The program which
  556. writes information into the file must reset the ending block
  557. number to the actual last block used, and then mark the file
  558. closed, by setting its status byte to $FF. When the Apex
  559. Exec regains control, it will correct the directory of the unit
  560. to reflect the actual size of the file.
  561.  
  562. If the files are to be accessed in a byte serial fashion, as is
  563. the case with many programs, assemblers for example, then the
  564. files can be treated exactly like any other byte I/O device and
  565. accessed through the byte I/O device handler (device 3). In this
  566. case, the program need not do anything special at all.
  567.  
  568. As with any device, the program must open the device for input
  569. and/or output, read or write bytes to the device and close the
  570. device before it runs to termination. These operations are all
  571. standard functions which every device handler must be able to
  572. perform.
  573.  
  574. If a file is written, but not closed, it will be discarded unless
  575. the Apex command CLOSE is used before any new files are opened.
  576.  
  577. BACKUP FILES
  578. 
  579. Whenever a file is modified, a new copy is made, and we have a
  580. choice. We can either delete the old version, or we can rename
  581. it so that the same name does not occur twice in the directory.
  582. In Apex, the choice is yours.
  583.  
  584. In some instances, the Apex will simply delete the original
  585. file, leaving only one file with the name. In some instances, it
  586. will change the extension of the original file to "BAK". In this
  587. case, you always have at least one old version of the file in
  588. case of disaster. The system wide switch BACKUP turns the option
  589. on or off. It is changed by the DO and NO commands to Apex.
  590.  
  591. Even when we have the backup switch on, we do not want every
  592. file name duplication to produce backups. Generally we only want
  593. to backup source files. To control this, every program which
  594. produces an output file has its own local backup switch. This
  595. switch is changed by the SET utility. In order for backups to be
  596. produced, both the local and the system wide backup switches
  597. must be on.
  598.  
  599. Apex protects BAK files by preventing you from changing them. In
  600. order to work with them as normal files, you must rename them.
  601.  
  602. SYSTEM FILES
  603. 
  604. In Apex there are special system files with the SYS extension.
  605. They are:
  606.  
  607. RESCOD.SYS
  608.     This file contains the resident portion of Apex. It
  609.     is only required on bootable system units. It is 9
  610.     blocks long and must begin in block 17.
  611.  
  612. SYSTEM.SYS
  613.     This file contains the command executive. It is required
  614.     on all system units. It is 65 blocks long and can reside
  615.     anywhere on a unit.
  616.  
  617. SCRATCH.SYS
  618.     This file is the space Apex will use to save the part
  619.     of memory that the command executive uses. It is required
  620.     by several system functions and will normally exist on
  621.     every system unit. It is 65 blocks long and can reside
  622.     anywhere on a unit.
  623.  
  624.             DEFAULTS
  625.             ========
  626. 
  627.  
  628. Apex has a powerful default mechanism which will allow commands
  629. to be extremely abbreviated. These defaults may take a little
  630. getting used to at first, but in time you will develop a feel
  631. for just how much you really need to type to get Apex to do what
  632. you want. The syntax diagrams in this manual will help you
  633. determine the range of possibilities.
  634.  
  635. Defaults in Apex are based upon a few basic concepts which are
  636. described here.
  637.  
  638. Apex has a "system" unit and a "task" unit. The system unit is
  639. initially the unit you booted from, but can be changed by the
  640. SYSTEM command. The task unit is the unit number attached to the
  641. default file name, which can be changed with the DFILE command.
  642.  
  643. In operation, Apex will use the system unit for storing such
  644. things as default information, the date etc. It will also,
  645. unless told otherwise, look on the system unit for programs you
  646. request in a run command. Hence, the system unit is where you
  647. normally keep your commonly used programs such as editors and
  648. assemblers. The task unit is the default for all other
  649. operations. For example, input and output files will default to
  650. the task unit. Hence the task unit is where you keep the program
  651. you are working on.
  652.  
  653. Apex has a system wide default file specification which will be
  654. used whenever no other file name is specified. The default file
  655. has a unit and extension attached to it. The unit will be the
  656. task unit and the extension will be used when all other sources
  657. of a reasonable extension have no suggestions to make.
  658.  
  659. In general, the context of a command will suggest an extension
  660. which has a higher priority than the default extension, but a
  661. lower priority than an explicily given extension. For example,
  662. the GET command will suggest an extension of SAV for its file
  663. argument.
  664.  
  665. However, extensions are for your convenience, not Apex's, so you
  666. may invent and use any extensions you please. This leads to a
  667. possible danger. If you spell it out, Apex will happily try to
  668. run a text file or edit a runable program image.
  669.  
  670. GENERAL DEFAULT STRUCTURE
  671. 
  672. Basically, the default structure automatically provides file
  673. names whenever the user omits them. The system default file is
  674. used to control the current working file. If an OPEN or run
  675. command is entered without an argument and followed by a space,
  676. the system default file name will be taken as the input and/or
  677. output file for that command.
  678.  
  679. Each saved program can automatically control its input and
  680. output extensions. This enables programs like the assembler to
  681. specify BIN for the binary output file, or the XPL0 loader to
  682. specify I2L as its input file extension. These suggested
  683. extensions are kept in the program specific part of the system
  684. page and can be set up using the SET utility.
  685.  
  686. When these two systems of defaults are used together, they
  687. eliminate most of the typing during program development.
  688.  
  689. For example, let's say that you are writing a machine language
  690. program to catalog your stamp collection. You have decided to
  691. call the program "STAMP". Since this file will be the active
  692. working file, you will set the system default file name to this
  693. file with the DFILE command. Assuming you want unit 1 to be the
  694. task unit, you could type:
  695.  
  696.     DFILE 1:STAMP.P65
  697.  
  698. Generally, you will be editing, then assembling, then loading
  699. and finally saving the file. Initially you must make the file
  700. for the first time. This can be done in several ways, but simply
  701. typing MAKE followed by a space and a return will do the job.
  702.  
  703. If you then type the name of the editor (probably EDIT) followed
  704. by a space, the editor will take STAMP.P65 as it's input and
  705. output file.
  706.  
  707. When you are finished editing, you are ready to assemble.
  708. Running the assembler will read STAMP.P65 as it's input file.
  709. But, because the assembler has a special extension for it's
  710. output file, it will create STAMP.BIN as the output file.
  711.  
  712. As soon as the file is assembled, you will probably want to
  713. load. Typing LOAD followed by a space will set STAMP.BIN as the
  714. load file for the loader. No output file will be set, because
  715. the loader default indicates that no output file is needed.
  716.  
  717. The loader will return to the Apex Exec. At this point, you can
  718. use the SWAP or START commands to test the program or you can
  719. save the program with the SAVE command. Note that, unless the
  720. system page properties of the program were set up as a part of
  721. the loading process, the START command cannot be used yet, and
  722. the SAVE command will need to be told what areas of memory to
  723. save.
  724.  
  725. After the save, SET (space)(return) can be used to setup the
  726. program's run parameters.
  727.  
  728. The default structure is set up so that it can be overridden in
  729. several different ways. Generally, the defaults can be
  730. overridden by explicitly spelling out part of the input or
  731. output file specification. Here are some examples:
  732.  
  733. EDIT A.FIL<A.FIL    Opens "A" for input and "A" for output.
  734.  
  735. EDIT B.FIL<A.FIL    Opens "A" for input and "B" for output.
  736.  
  737. EDIT B.FIL        Opens "B" for both input and output.
  738.  
  739. EDIT B.FIL<        Opens "B" for output only.
  740.  
  741. EDIT B            Opens "B" with the default extension.
  742.  
  743. EDIT <B.FIL        Opens "B" for input only.
  744.  
  745. EDIT(SPACE)        Opens input and output default files.
  746.  
  747. EDIT .TMP<.FIL        Opens the file with other extensions.
  748.  
  749. EDIT 2:TEMP<:        Opens a new file for output, same input.
  750.  
  751.  
  752. Refer to the description of the OPEN and run commands for
  753. further discussion (pgs 38,42).
  754.  
  755.             SWAPPING
  756.             ========
  757. 
  758.  
  759. An Apple II has a relatively small memory space. Even a fully
  760. expanded system is only 48K. A typical operating system runs in
  761. 10-20K, so that even with fully expanded memory, the operating
  762. system uses up one third of the memory. 
  763.  
  764. Apex deals with this problem by sharing the memory between the
  765. user program and the operating system. If the program is smaller
  766. than about 20K, the operating system and the user program can
  767. fit in main memory without any conflict. If the program grows
  768. larger than 20K, it is allowed to over-write part of the Apex
  769. Exec. Whenever it is needed again, the Exec is simply reloaded
  770. from disk.
  771.  
  772. In the situation where a large program and the operating system
  773. must co-operate, the Apex Exec is swapped in and out of memory
  774. as needed. The swapping operation involves saving the resident
  775. program in a scratch area on the disk and then reloading the
  776. Exec. Thus, an exact copy of the current state of the program
  777. can be preserved while the Exec is in memory. Since Apex is
  778. fast, the entire swapping operation takes only a few seconds.
  779. The swapped out program can be restarted or can be manipulated
  780. by the operating system. Using this technique, every program can
  781. use nearly all of the computer's memory. 
  782.  
  783. WHEN YOU SWAP AND WHEN YOU DON'T
  784. 
  785. Even the few seconds of swap time is unneccessary most of the
  786. time, since you are typically re-entering Apex without caring
  787. about the previous memory content. So the "normal" entry to Apex
  788. is the REENTER point, which does not save the current memory
  789. content. However, if you want to preserve the current memory
  790. content, for later use, or because you want to make a SAV file
  791. out of it, you must swap. Also, error conditions should swap
  792. whenever possible so that the debug process is simpler. Thus,
  793. there is a SAVER entry point to Apex which is taken whenever a
  794. program is aborted with the Control-P key or when you use
  795. Control-Y to re-enter Apex from the Apple ROM monitor. It is
  796. also taken as the standard exit of loaders which setup a memory
  797. content for future use. Apex entry points are discussed further
  798. under that topic (pg 36).
  799.  
  800. You can return to a swapped out memory content with the SWAP and
  801. START commands to Apex. You can save a swapped out memory
  802. content in a file with the SAVE command. You can restore a SAVEd
  803. memory content with the run and GET commands.
  804.  
  805. RUNNING WITHOUT SWAPPING
  806. 
  807. The Apex system files use a significant amount of space on an
  808. Apple mini-floppy. If you have only one drive you may encounter
  809. a program which simply cannot be worked with on a single system
  810. unit.
  811.  
  812. It is possible to go through a sequence of running programs
  813. which do not use the command excutive memory space without a
  814. valid system unit on line.
  815.  
  816. So, in extreme cases, with care, you can use a non-system disk
  817. to edit and assemble large programs. The loading process will
  818. require a system unit however.
  819.  
  820. The distributed assembler and editor are setup to not overlay
  821. the Apex Exec. This limits their capability somewhat. You can
  822. set them up to use more memory, by changing the appropriate
  823. system page parameters (pg. 33). However then they will have to
  824. be be run from a valid system unit.
  825.  
  826.  
  827.             DATES
  828.             =====
  829. 
  830.  
  831. One of the most reasonable ways to keep track of your work,
  832. particularly on floppy disks, where numerous revisions of a
  833. program tend to get scattered over many disks, is the use of
  834. dates on files. Apex maintains a system date which it saves on
  835. the system unit and which it will attach to every file as it is
  836. created or when it is modified. It is a very good idea to get
  837. used to maintaining the system date right from the start. The
  838. DATE command is used to change the system date, and the /L switch
  839. on the DIRECTORY command is used to see the dates attached to
  840. files.
  841.  
  842.  
  843.             ERRORS
  844.             ======
  845. 
  846.  
  847. Apex is verbose and quite clear in most situations. Its messages
  848. and this manual should be sufficient to follow its normal
  849. operation.
  850.  
  851. However, in the case where an error occurs in the runtime
  852. system, the error message is cryptic. You get a question-mark
  853. and a number alone on a line. Normally the number is 3, which
  854. indicates an I/O error. The most common I/O error is an attempt
  855. to access a disabled disk unit, such as a drive with the door
  856. open, or with no disk in it. Any other number indicates an
  857. unreasonable condition in the runtime system and probably
  858. means that that area of memory has been changed and you must
  859. reboot.
  860.  
  861.         APEX SYNTAX
  862.         ===========
  863. 
  864. This manual will not discuss the Apex syntax in any detail. The
  865. examples should be all you need. However a few points must be
  866. made here.
  867.  
  868. Apex commands are usually one line long. The RETURN key ends the
  869. command. Until that time the line is being processed by the
  870. console handler and so the command editing features of Apex
  871. depend upon the handler you have. See that section for details
  872. (pg. 29).
  873.  
  874. If a command line is given to Apex, and is incomplete in a
  875. determinable way, Apex will simply request more input, which
  876. results in a new flashing cursor on the next line.
  877.  
  878. Apex regards the slash character as the command line switch
  879. prefix. Hence, any slash character, and the character which
  880. follows it, are not a normal part of the command. There are also
  881. other special characters used to terminate programs etc. These
  882. are properties of the console handler and may vary. However
  883. there are fairly strong conventions for these, which this manual
  884. will assume at times.
  885.  
  886. Numbers given to Apex are taken as sixteen bit unsigned
  887. integers. The minus and period characters are not parts of
  888. numbers and will usually be taken as delimiters.
  889.  
  890. Numbers in Apex can be in decimal or in hexadecimal. If the
  891. number is to be taken as hexadecimal it must be prefixed by a
  892. dollar-sign.
  893.  
  894.             SWITCHES IN APEX
  895.             ================
  896.  
  897.  
  898. COMMAND LINE SWITCHES
  899. 
  900. Some commands use a special feature called "command switches".
  901. Switches are special character included with a command that
  902. modifies the action of the command. Command line switches are
  903. preceeded by a FORWARD SLASH character (/). Any character
  904. following a by a forward slash will be taken as a switch
  905. character. Switches can be placed anywhere within the command
  906. line. For example:
  907.  
  908.     DIRECTORY/L
  909.  
  910.  
  911. SYSTEM WIDE SWITCHES
  912. 
  913. In Apex there are three system-wide switches which are changed
  914. by the NO and DO commands. These are the BACKUP, CHECK and PACK
  915. switches.
  916.  
  917. The BACKUP switch will allow or prevent the backup file feature.
  918. With BACKUP on the source files you are working with will not be
  919. erased until they are two revisions old. See the section on Apex
  920. files (pg. 8).
  921.  
  922. If the CHECK switch is on, Apex will check every output file to
  923. make sure it is readable before deleting or renaming any old
  924. version of the file that may exist.
  925.  
  926. If the PACK switch is on, Apex will take time out every now and
  927. then to move files on the disk to keep the empty space on the
  928. unit more optimal. Packing will only move the most recently
  929. closed output file so fragmentation of the empty space can still
  930. occur in time, but it takes much longer with the pack switch on
  931. than with it off.
  932.  
  933. SAVE FILE SWITCHES
  934. 
  935. Each SAV file which expects to produce an output file has three
  936. switches to control this file. They are the BACKUP, SIZE and
  937. KEEP DATE switches. These switches are maintained in the program
  938. specific portion of the system page and may be setup manually or
  939. with the Apex SET utility.
  940.  
  941. The SAV file BACKUP switch tells Apex whether this program
  942. produces an output file which is a revision of its input file.
  943. Progams which merely revise files can reasonably backup the old
  944. version of the file. An editor is an example of such a program.
  945. Programs, such as assemblers, which produce completely different
  946. output files simply leave the input file alone and so have their
  947. local backup switch off.
  948.  
  949. If the SIZE switch is on, Apex will require that the available
  950. space for the output file be at least as large as the input
  951. file. This is a useful protection for editors and other programs
  952. which tend to make files larger.
  953.  
  954. The KEEP DATE switch controls the date assigned to a file. If it
  955. is on, then the date on the output file will be obtained from
  956. the date that the input file had; otherwise, the file will be
  957. dated with the system date.
  958.  
  959.             MEMORY USE
  960.             ==========
  961. 
  962.  
  963. There is a diagram of apex memory use in this manual. It should
  964. be referred to in conjunction with this discussion.
  965.  
  966. At the most central level, there is a section of Apex which must
  967. be resident at all times. This section lives in the highest 4k
  968. of your machine and contains the basic system functions, the
  969. disk drivers, and the code to handle the keyboard and screen.
  970.  
  971. The highest page of your memory, the section from $BF00 thru
  972. $BFFF, is the central communications area for Apex. It is
  973. through this page that all programs running under Apex will
  974. communicate with Apex itself.  This page is discussed in detail
  975. elsewhere (pg.31).
  976.  
  977. At the next level we have another 4K section of memory, called
  978. the system residual area, which normally contains Apex device
  979. handlers and the code for certain run-time system functions.
  980. When your programs are loaded, this section of code remains in
  981. memory and so its funtions are available to your programs.
  982. However, your program is free to overwrite this area with other
  983. information if required. This area of memory is also used as the
  984. place where other run-time utility packages for specific
  985. applications are placed. The normal contents of this area will
  986. be restored when your program runs to completion.
  987.  
  988. The next level, the Apex Exec, is overlaid onto a 12k section of
  989. memory below the system residual area. Programs which do not use
  990. this area of memory can leave the Apex Exec resident while they
  991. run by setting the SYBOMB flag in the system page to FALSE=0. If
  992. your program does use this area of memory, the SYBOMB flag
  993. should be set to TRUE=$FF, which will cause Apex to reload the
  994. Exec and the residual area when your program runs to termi-
  995. nation.
  996.  
  997. Apex allocates page zero (hex addresses $0 through $FF) as
  998. follows. The first 32 bytes are considered very temporary and
  999. are never saved. Apex will frequently use the first six of
  1000. these. The next 48 bytes are reserved for use by the ROM in your
  1001. Apple and should not be used by normal programs. The remainder,
  1002. from $50 through $FF is for use by your programs and will be
  1003. saved with them in SAV files.
  1004.  
  1005. The first 80 bytes of the system page at $BF00 are a part of a
  1006. user program. They are used to describe various properties of
  1007. the program which Apex needs to know about. Therefore these
  1008. bytes are also saved with a program. The SET utility can be used
  1009. to modify these locations in a SAV file.
  1010.  
  1011. Every program which uses Apex files must pay some attention to
  1012. the location of its input and output buffers which are defined
  1013. in the system page. This is discussed in more detail elsewhere
  1014. (pg.32).
  1015.  
  1016. Beyond these memory allocations Apex leaves the rest of your
  1017. Apple alone. Thus the maximum possible flexibility is
  1018. maintained.
  1019.  
  1020. OTHER MEMORY USE
  1021. 
  1022. The standard bootstrap process will use pages 3, 8 and 9 as well
  1023. as the memory from $6000 upward.
  1024.  
  1025. The SAVER entry process will use memory from $A000 upward,
  1026. saving $6000-$9FFF in the scratch area of the system unit.
  1027.  
  1028. The console handler will use page 2 as the input line buffer.
  1029. Also, by using ROM routines, it will affect the areas of page
  1030. zero between $20 and $4F.
  1031.  
  1032. The bootstrap process will setup the auto-start and Control-Y
  1033. vectors in page 3.
  1034.  
  1035. Be warned that the Apple BASICs will use page zero locations
  1036. other than those set aside for ROM use.
  1037.  
  1038.             DEVICE HANDLERS
  1039.             ===============
  1040. 
  1041.  
  1042. Apex has a device independant mechanism for accessing periperal
  1043. devices which can be made to communicate in a serial byte
  1044. stream.  Each such device has a handler. Each handler has a set
  1045. of five standard functions which it must be able to perform. In
  1046. addition, a device may have other functions which it can perform
  1047. as well, but these will be different from one device to another.
  1048.  
  1049. Handlers in Apex are "plugable". That is, you can replace any
  1050. handler in Apex by another piece of code without affecting
  1051. anything except the funtioning of that device. This is how you
  1052. tailor Apex to your specific printer for example.
  1053.  
  1054. Apex handlers are not sacred. You are free to change them at
  1055. your whim. For example, if you are used to some line delete
  1056. character other than Control-X then you are free to change the
  1057. console handler accordingly.
  1058.  
  1059. Of course, handlers are a convenience, not a rigid structure.
  1060. Your programs need not use the handlers; after all, this is your
  1061. machine! Certain programs, in fact, will find the formalized
  1062. structure of handlers a problem, and so will contain their own
  1063. code to drive the device in question. The classic case is
  1064. editors which interface with the the most complex periperal of
  1065. all - you. But note that if a program does use the handlers then
  1066. it will be "device independant" and will be able to use any
  1067. device that you can create a handler for. Since no system stays
  1068. the same for very long, this is a major advantage.
  1069.  
  1070. On the Apple II, most peripheral devices are supplied with an on
  1071. board ROM which is supposed to contain the code necessary for
  1072. driving the device. If this mechanism is satisfactory for a
  1073. particular device, then the Apex handler becomes simply a series
  1074. of jumps to the appropriate slot address, $CX00. However, it is
  1075. common for the ROM code to be oriented to some special purpose,
  1076. other than the one you have in mind, and so the handler becomes
  1077. a little more complex. Apex gives you this freedom.
  1078.  
  1079.  
  1080. HANDLER ENTRY POINTS
  1081. 
  1082. Each handler must begin with five jump vectors which occur in a
  1083. defined sequence and perform specified functions. These are
  1084. listed below. Every handler function must return with the carry
  1085. flag reflecting the success or failure of the requested
  1086. function. A set carry flag indicates failure. Data is passed to
  1087. and from handlers in the accumulator and the Y register as
  1088. neccessary for the specific function. A handler need not
  1089. preserve any registers and should never be assumed to do so.
  1090. Handlers may not change any system page information, and may
  1091. not use any locations in page zero except the first six.
  1092.  
  1093. 1.    OPEN FOR INPUT        ENTRY=0
  1094.  
  1095. This entry point must initialize the input side of the device.
  1096. This entry point must always have been called before the INPUT
  1097. entry is ever called.  This entry should also check for the
  1098. existence and readiness of the device to perform byte input.
  1099. It should flush the input buffer if any.
  1100.  
  1101. 2.    OPEN FOR OUTPUT        ENTRY=3
  1102.  
  1103. This entry point must initialize the output side of the device.
  1104. This entry point must always have been called before the OUTPUT
  1105. entry is ever called.  This entry should also check for the
  1106. existence and readiness of the device to perform byte output.
  1107. It should reset the output buffer if any.
  1108.  
  1109. 3.    INPUT A BYTE        ENTRY=6
  1110.  
  1111. This entry point will fetch a byte from the device and return
  1112. it in the accumulator.
  1113.  
  1114. 4.    OUTPUT A BYTE        ENTRY=9
  1115.  
  1116. This entry point will output the byte in the accumulator to
  1117. the device.
  1118.  
  1119. 5.    CLOSE DEVICE        ENTRY=12
  1120.  
  1121. This entry point will terminate access to the device. Output
  1122. buffers, if any, are flushed. If the device can be powered up
  1123. and down under program control, this entry should turn it off.
  1124.  
  1125.  
  1126. ACCESSING DEVICE HANDLERS
  1127. 
  1128. The standard method of calling a device handler to perform a
  1129. function is as follows: The number of the device to be accessed
  1130. is placed in the system page location NOWDEV at $BF5C. The X
  1131. register is set to the number of the function to be performed.
  1132. The Accumulator and Y registers are setup, if required, and a
  1133. subroutine call (JSR) is made to the system entry point KHAND at
  1134. $BFD9. KHAND will use the device handler table to dispatch to
  1135. the correct entry point.
  1136.  
  1137. INSERTING DEVICE HANDLERS.
  1138. 
  1139. In order for KHAND to be able to find the device in question the
  1140. base address of its handler must be placed in the device driver
  1141. table in the system page. Device drivers can be anywhere in
  1142. memory, but, in order to have them automatically loaded, they
  1143. should be placed in the system resident or system residual area.
  1144. The system residual area is saved in the system file SYSTEM.SYS
  1145. when the INIT command to Apex is performed. The system resident
  1146. area and the system page area containing the device driver
  1147. tables is saved in the file RESCOD.SYS when the system utility
  1148. BOOTER is used to rewrite the bootstrap.
  1149.  
  1150. STANDARD DEVICE HANDLERS
  1151. 
  1152. Every implementation of Apex should have the following device
  1153. handlers:
  1154.  
  1155. DEVICE 0: The console, as a line by line device. This handler
  1156. should provide a means for the user to correct the console input
  1157. line before making the bytes available to the calling program.
  1158. The open input entry should clear the input line. This handler
  1159. should deal with the echoing of the input back to the output.
  1160.  
  1161. DEVICE 1: The console, as an unbuffered, non-echoed, character
  1162. by character device. It should never give errors. This handler
  1163. should deal with the trap characters (normally Control-C and
  1164. Control-P) which can exit or abort the currently running
  1165. program.
  1166.  
  1167. DEVICE 3: This handler provides access to the open Apex files as
  1168. byte by byte streams. The open for input entry should reset the
  1169. input file to its beginning. The close entry should write an
  1170. end-of-file mark to the output file and close it.  A file which
  1171. is written but never closed should be discarded.
  1172.  
  1173. DEVICE 7: A null device. It provides endless end-of-file marks
  1174. on input and swallows endless amounts of output. It never gives
  1175. errors. Typically this device is used as a sink for unwanted
  1176. output, such as an assembly listing which is not needed.
  1177.  
  1178. Most implementations of Apex will also have a printer handler as
  1179. device 2 and many will have a serial RS232 port as device 4.
  1180. Devices 5 and 6 are available for other periperals.
  1181.  
  1182.         THE CONSOLE DEVICE
  1183.         ==================
  1184. 
  1185.  
  1186. This section gives some specifics on the standard console
  1187. handler supplied with Apex. Listings are included, both to serve
  1188. as an example handler, and so that the exact functioning can be
  1189. determined.
  1190.  
  1191. Devices 0 and 1 in Apex are the standard "console" which
  1192. consists of the Apple keyboard and TV screen. In some config-
  1193. urations, the console device will be a terminal accessed through
  1194. a serial interface or an alternative TV display card. In these
  1195. cases the console device handler may be different from the
  1196. handler described here.
  1197.  
  1198. The difference between device 0 and device 1 is that device 0 is
  1199. line buffered and automatically echoed, while device 1 is not.
  1200.  
  1201. The basic console handler, device 1, deals with keyboard input
  1202. as follows: Most keys produce the correct 7 bit ASCII code one
  1203. would expect. Note that, unlike the Apple ROM routines, the high
  1204. bit of the character is not set. Certain keys have special
  1205. functions.
  1206.  
  1207. The trap keys are as follows: Control-C will exit immediately
  1208. through the current program's normal exit vector. Control-P will
  1209. exit through the current program's abort exit vector.
  1210.  
  1211. Some keys are translated to other characters: Control-O will
  1212. return the ASCII code for backslash ($5C) while Control-K will
  1213. return the ASCII code for left square bracket ($5B). These are
  1214. provided to round out the ASCII set which can be generated from
  1215. the standard Apple keyboard. Backspace, or Control-H, which is
  1216. generated by the left arrow on the apple keyboard, is changed to
  1217. ASCII rubout ($7F).
  1218.  
  1219. In addition, the key Control-Shift-M is used to force the Apple
  1220. keyboard to generate lower case. This key toggles the case
  1221. conversion on and off in sequence. When the lower case switch is
  1222. on, conversion takes place on all 64 normal ASCII upper case
  1223. codes.
  1224.  
  1225. On the output side of device 1, the routine will monitor the
  1226. keyboard and hang waiting for another key to be struck if
  1227. Control-S was struck on the keyboard.
  1228.  
  1229. The device 1 output routines will interpret carriage return,
  1230. line feed, tab, form feed, bel, backspace and rubout.
  1231. In addition, they will convert all lower case characters to
  1232. inverted video and all control characters, that do not have an
  1233. operational function, into flashing characters.
  1234.  
  1235. Device 0 performs using device 1, so in general the above
  1236. applies.
  1237.  
  1238. The line input routine interprets the screen edit functions that
  1239. are documented in the standard Apple II reference manual. Thus
  1240. left and right arrow, and the escape sequences perform as usual.
  1241. Control-X is the line cancel function. The limitations of the
  1242. standard Apple screen editing features still apply. In addition,
  1243. the input routine will discard occurences of line feed
  1244. (Control-J) and Control-Z.
  1245.  
  1246. Device 0 has the ability to input from files by using deferred
  1247. console execute mode. A flag in the system page controls this
  1248. function, which will be used in future releases of Apex.
  1249.  
  1250. The console handler uses the Apple ROM windowing routines but
  1251. does not use the vectors at $36 and $38. These vectors are
  1252. modified by too many Apple programs to be reliable. You may wish
  1253. to use them to contruct a "variable" device handler, which uses
  1254. the Control-P command to the Apple ROM Monitor and can talk to
  1255. any slot.
  1256.  
  1257.  
  1258.         APEX SYSTEM PAGE
  1259.         ================
  1260. 
  1261.  
  1262. The memory area from $BF00 through $BFFF is used to communicate
  1263. between programs and Apex itself.  This page is called the
  1264. System page.  It's organization cannot be changed without major
  1265. modifications to Apex and all programs which run under Apex.
  1266.  
  1267. The area between $BF00 and $BF4F is used to store all the global
  1268. parameters of the particular program in memory at the time. It
  1269. is saved with, and read from every SAV file.
  1270.  
  1271. The area from $BF50 through $BFFF is used to store the system
  1272. wide global information that does not change with the
  1273. particular program which happens to be resident.
  1274.  
  1275. The funtion of the various globals is covered briefly in this
  1276. section. Refer to the listings and to other parts of this manual
  1277. for more detail.
  1278.  
  1279. START AND EXIT VECTORS.
  1280. 
  1281.  
  1282. Each program has two start and three exit vectors. The start
  1283. vectors should be jumps to the respective starting points of the
  1284. program. The start and restart vectors are usually the same.
  1285.  
  1286. The exit vectors are the way in which a program must reenter
  1287. Apex when it runs to completion. A program should not normally
  1288. exit to the actual Apex entry vectors, instead it should exit to
  1289. these vectors which will, in turn, enter Apex. This procedure
  1290. provides a standard way to change the exit mechanism of programs
  1291. in exceptional cases, such as to disable the trap exit capa-
  1292. bility in editors, or to implement a batch processing facility
  1293. under Apex.
  1294.  
  1295. VEXIT    Taken when a program runs to normal termination, or
  1296.     when the Control-C key is typed.  Normally points to the
  1297.     Apex REENTER point at $BFD0.
  1298.  
  1299. VERROR    Taken when a program exits on a fatal error condition.
  1300.     This normally points to the Apex RELOAD entry point at
  1301.     $BFD6.
  1302.  
  1303. VABORT    Taken when a program is exited by typing the Control-P
  1304.     key. It normally points to the Apex SAVER entry point
  1305.     at $BFD3.
  1306.  
  1307.  
  1308. SAVED IMAGE PARAMETERS
  1309. 
  1310. The globals DSKMEM and DSKSIZ reflect the values that USRMEM and
  1311. PROSIZ had when the program was saved.  They are set by Apex and
  1312. should not be changed or set in normal use.
  1313.  
  1314. PROGRAM SPACE PARAMETERS
  1315. 
  1316. The globals USRMEM and PROSIZ tell Apex where and how large
  1317. the program to be saved is.  USRMEM is the first address, other
  1318. than the page zero area, to be saved.  PROSIZ is the number of
  1319. pages beyond USRMEM to be saved.  These values are setup by
  1320. the Apex SAVE command when it is used with arguments.
  1321.  
  1322. I2L PARAMETERS
  1323. 
  1324. These parameters are used for system utilities and are not to be
  1325. affected by normal programs. The I2LFLG location should contain
  1326. FALSE=$00 for all normal programs.
  1327.  
  1328. BUFFERS
  1329. 
  1330. The locations OTBUFD,OTBUFE,INBUFD and INBUFE are used to
  1331. determine what area of memory the byte I/O to disk files handler
  1332. (device 3) will use as input and output buffers. These
  1333. parameters are part of the program space so that each program
  1334. can select the buffers individually.
  1335.  
  1336. These buffers must begin on a page boundary and extend for an
  1337. integral number of pages.
  1338.  
  1339. Note that the KSCAN routine will use the input buffer as a place
  1340. to put the directory. Thus the input buffer pointers must be
  1341. valid, and the buffer at least three pages long, whenever KSCAN
  1342. is used.
  1343.  
  1344. The Apex Exec will use the area from $6000 through $63FF for its
  1345. buffers. The standard BIN file loader will preset the buffers to
  1346. the memory area from $A000 through $AFFF.
  1347.  
  1348. If Apex is entered via the RELOAD or SAVER entry points KSCAN
  1349. will be used with an input buffer at $A000 to find the system
  1350. files.
  1351.  
  1352. OTHER PROGRAM SPECIFIC GLOBALS
  1353. 
  1354. The rerun flag RERUNF is preset by Apex to zero whenever a
  1355. program is run. The program itself may modify and test this
  1356. byte at will.
  1357.  
  1358. The default input and output extensions are the extensions for
  1359. input and output files which the program will use. There are two
  1360. special codings for these:
  1361.  
  1362. 1) The coding "@@@" means that the program uses the corres-
  1363. ponding file but has no suggestion to make about extensions. In
  1364. this case the OPEN function of Apex will use the extensions from
  1365. the system default file name as set by the DFILE command.
  1366.  
  1367. 2) The coding "   ", that is, three space charaters, means that
  1368. the program does not require this file. Apex will not allow the
  1369. corresponding file to be opened.
  1370.  
  1371. The byte DEFAUL holds the program specific switches.  These
  1372. are the SIZE, BACKUP and KEEP DATE switches.  A value of zero
  1373. in this byte corresponds to all switches off.
  1374.  
  1375. The SYBOMB flag tells Apex wether the user program uses the Apex
  1376. Exec space in memory. It should be TRUE=$FF if the program
  1377. disturbs any memory above $7000, and to FALSE=$00 otherwise.
  1378. Strange things will happen if this flag is wrong, particulary if
  1379. the flag incorrectly holds the special system value of $55. If
  1380. SYBOMB is set to false, Apex will use the area between $6000 and
  1381. $6FFF when the executive executes. However, Apex does not
  1382. require that this area have any particular initial content, so
  1383. both the user program and Apex may use the space alternately.
  1384.  
  1385. The byte USRTOP is intended to hold the (page number + one) of
  1386. the highest page the current program may use. This byte is
  1387. irrelevant (but should be set for cleanliness anyway) if the
  1388. program uses a fixed amount of memory. Some programs, such as
  1389. editors and assemblers, will use as much memory as possible so
  1390. they will use this byte to determine how much they are allowed
  1391. to use. The buffers should always have addresses higher than
  1392. (or begin at) this page.
  1393.  
  1394. USRTOP should be set with due regard for the SYBOMB flag. Both
  1395. the buffers and USRTOP should never be above $7000 if SYBOMB is
  1396. FALSE.
  1397.  
  1398.  
  1399. INPUT/OUTPUT FILE PARAMETERS
  1400. 
  1401. These areas are setup by the OPEN or run operations in Apex.
  1402. They remain valid while Apex loads and executes a program stored
  1403. as a SAV file. The program can therefore use them as a simple
  1404. way to get at the first input and output files.
  1405.  
  1406. Apex sets up the starting and ending block numbers, the unit
  1407. number and the directory number of the files. In addition, Apex
  1408. will set the corresponding flag byte (INFLG or OTFLG) to 1 if
  1409. the file area is setup and to 0 if no file was setup.
  1410.  
  1411. If the byte I/O to files handler is used, it will use these
  1412. parameters to access the input and output file as required.
  1413.  
  1414. Additional byte I/O input files may be opened by using the SCAN
  1415. entry point to the byte I/O handler. See the section on using
  1416. files (pg.10) and the listings.
  1417.  
  1418. THE UNIT DRIVER INFORMATION BLOCK
  1419. 
  1420. This is an area for use in communicating the multiple parameters
  1421. required by the unit drivers to those drivers. The system
  1422. functions KREAD, KWRITE and KSCAN use this block.  Refer to the
  1423. listings for the details.
  1424.  
  1425. THE DEVICE HANDLER TABLE
  1426. 
  1427. This is a table of eight addresses, one for each possible byte
  1428. I/O device handler. They contain the address of the start of the
  1429. handler. They are the ONLY way Apex knows about the handlers and
  1430. so they are all that you need change when handlers change or
  1431. move. Access to handlers is via the system function KHAND which
  1432. will use this address to compute the final address of the
  1433. routine to be executed (pg. 27).
  1434.  
  1435. OTHER SYSTEM DEPENDANT GLOBALS
  1436. 
  1437. The flag SYSENF is used by the Apex resident portion to
  1438. communicate with the non-resident portion, and is not for any
  1439. other use.
  1440.  
  1441. The parameters SYSDEV, SYSBLK and SWPBLK describe the current
  1442. system unit. A study of the resident code is required for a
  1443. complete understanding of when these values are valid.
  1444.  
  1445. The parameter DEVMSK indicates which Apex units are active on a
  1446. given system. See elsewhere for the bit mapping used (pg.6).
  1447.  
  1448. SYSDAT holds the current system date as a 16 bit integer formed
  1449. by the equasion:
  1450.  
  1451.     ((YEAR-1976)*16+MONTH)*32+DAY
  1452.  
  1453. The byte following SYSDAT is used to indicate the validity of
  1454. the system date.  When valid it should hold the "exclusive or"
  1455. of the "and" of the two bytes of the system date.
  1456.  
  1457.         APEX RESIDENT SYSTEM VECTORS
  1458.         ============================
  1459. 
  1460.  
  1461. If you look at the listings for the system page you will see
  1462. that Apex has a set of vectors which provide a single and stable
  1463. method for other programs (incuding the Apex Exec) to access the
  1464. code included in the resident portion of Apex.  This code should
  1465. never be accessed by any other means.
  1466.  
  1467. APEX ENTRY POINTS
  1468. 
  1469. There are three ways in which you may enter Apex from the
  1470. outside. They all assume that the resident memory area has
  1471. been correctly setup by the bootup process. The entries are:
  1472.  
  1473. REENTER:($BFD0)
  1474. This entry point assumes that Apex has been recently run and has
  1475. all its parameters correctly set. If you enter Apex here, it
  1476. will decide wether or not it needs to reload, and proceed
  1477. accordingly. This entry point will assume that the system unit
  1478. information in the system page is current. The keyboard escape
  1479. Control-C will re-enter Apex by this vector.
  1480.  
  1481. SAVER:($BFD3)
  1482. This entry point will reload Apex, but will first save the
  1483. current memory image in the file SCRATCH.SYS. It is used if the
  1484. Apex commands SWAP, START or SAVE will subsequently be used. The
  1485. keyboard escape Control-P will re-enter Apex through this
  1486. vector.
  1487.  
  1488. RELOAD:($BFD6)
  1489. This entry point is the cold start entry for Apex. It will
  1490. reload from the system unit independant of the state of the
  1491. system page. If Apex is started from a different system unit
  1492. this entry point should be used.
  1493.  
  1494. APEX RESIDENT SYSTEM FUNCTIONS
  1495. 
  1496. Some resident system funtions are standard 6502 subroutines
  1497. which perform some generally useful task. These routines may
  1498. change any registers and will return with the carry flag set if
  1499. they failed to perform their task, and clear otherwise.
  1500.  
  1501. KHAND    This allows general device independant access to the
  1502.     device handlers. See the section on handlers (pg. 25).
  1503.  
  1504. KSCAN    This routine provides a simple means for finding files
  1505.     by name on Apex units.  Examining the code for this
  1506.     routine will clarify the Apex directory format.
  1507.  
  1508. KRESTD    This routine will reset the disk driver routines.
  1509.  
  1510. KREAD    This routine is the basic means by which all block
  1511.     oriented reads are done from Apex units. It performs
  1512.     the read in accordance with the parameters placed in
  1513.     the unit driver information block. See the listings.
  1514.  
  1515. KWRITE    This is the companion routine to KREAD.
  1516.  
  1517. The other vectors provide paths for the basic program execution
  1518. functions required by the Apex Exec. They would not normally be
  1519. used by user programs.
  1520.  
  1521.             COMMANDS
  1522.             ========
  1523. 
  1524.  
  1525. Commands are instructions to the operating system to perform
  1526. specific operations. A command can be executed by typing the
  1527. command on the keyboard, followed by a CARRIAGE RETURN. All of
  1528. the commands in Apex can be abbreviated to two characters. For
  1529. example DIRECTORY can be abbreviated to DI.
  1530.  
  1531. Many commands take arguments. The arguments generally clarify or
  1532. elaborate upon the command's action. A SPACE character is used
  1533. to separate a command from the argument. For example: 
  1534.  
  1535.     [COMMAND] [argument]
  1536.  
  1537. The following pages outline only the specific aspects of each
  1538. Apex command. To develop a complete understanding of the
  1539. commands you must read this entire manual.
  1540.  
  1541. RUN
  1542. 
  1543. Most operating systems have a "RUN" command. This command is
  1544. used to execute any program which has been saved as a file. In
  1545. Apex, the run command is an implied command. Files are executed
  1546. simply by typing the name of the file.
  1547.  
  1548. This allows SAV files to be executed in such a way that they act
  1549. just like Apex commands. For example, let's say that you have a
  1550. program that handles your printer. It is customized so that it
  1551. does tabs and form feeds and understands all of the idiosyn-
  1552. crasies of your printer. This program could be named PRINT.SAV.
  1553. Then, whenever you wish to print a file, all you need to do
  1554. is type word "PRINT" followed by the name of the file you wish
  1555. to print.
  1556.  
  1557. In fact, this concept goes one step further: If a SAV file on
  1558. your system unit has the same name as a built in Apex command
  1559. then the file will have priority over the command. Thus you can
  1560. customize any Apex commands to your own needs without modifying
  1561. the basic Apex Executive.
  1562.  
  1563. A run command normally expects to find the file on the system
  1564. unit. If the file exists on some other unit, it can be run by
  1565. prefixing the name with the unit number:
  1566.  
  1567.     2:PRINT FROG.TXT
  1568.  
  1569. Executing a program can also have the effect of opening a file
  1570. for input or output or both. For example:
  1571.  
  1572.     EDIT FROG.FIL
  1573.  
  1574. Here Apex will load and execute the file EDIT.SAV. At the same
  1575. time, it will set up FROG.FIL as the input and output file. When
  1576. the editor is running, it will read information from the input
  1577. file and write information to the newly forming output file.
  1578. More information on opening files is given elsewhere
  1579. (pg.10, 42).
  1580.  
  1581. ZERO
  1582. 
  1583. The ZERO command clears the directory of all files, but does not
  1584. change any other data on the unit. This operation is usually
  1585. used to set up a new unit or to clear an old one for a different
  1586. use. The operation will effectively destroy all the file
  1587. information in directory, so use with caution. Apex will ask you
  1588. to verify before it will execute the operation. (Note: the
  1589. directory can usually be restored by using the backup directory
  1590. operations described below).  Example:
  1591.  
  1592.     ZERO 3
  1593.  
  1594. MAKE
  1595. 
  1596. This command creates a new file. For example:
  1597.  
  1598.     MAKE FROG
  1599. or
  1600.     MAKE 2:FROG.FIL=25
  1601. or
  1602.     MAKE FROG.FIL=28,150
  1603.  
  1604. The first number is the size of the file to be created. The
  1605. second is the block number to use. 
  1606.  
  1607. If no size is specified, Apex will create an empty text file
  1608. with the given name. If a size is specified, the allocated area
  1609. of the unit will not be cleared and any data left from previous
  1610. files will be unaffected.
  1611.  
  1612. If the starting block is not specified, Apex will start the file
  1613. at the first empty into which the file fits. If the starting
  1614. block is given, the file will begin at that block and extend for
  1615. the specified number of blocks.
  1616.  
  1617. The MAKE command does not check for file conflicts in any way.
  1618. Overlapping files and files with conflicting names can be
  1619. created. This allows the MAKE command to be used for error
  1620. recovery or other special purposes. In a situation where the
  1621. directory has been destroyed and the backup directory is
  1622. invalid, some files could be restored by setting up dummy files
  1623. across the unit and examining the files until the lost
  1624. information is found. A laborious process, but a life saver when
  1625. the information is important.
  1626.  
  1627. MAKE can also be used to set up files in special configuratons
  1628. to exchange disks with other operating systems.
  1629.  
  1630. DIRECTORY
  1631. 
  1632. The directory command prints information about the active files
  1633. contained on a unit.  It can be used with no argument, a unit
  1634. number argument or a file specification argument.
  1635.  
  1636. With no file specification argument, the directory command
  1637. prints a directory of all the files on a unit. With a file
  1638. specification, information about that specific file will be
  1639. printed. When fuzzy file names (* and ?) are used, information
  1640. about each match is printed. As described above, a star (*) will
  1641. match any file name or extension and a question mark will match
  1642. any character. Thus
  1643.  
  1644.     DIR 1:*.P65
  1645.  
  1646. will print information on any file with the extension "P65" on
  1647. unit 1 and
  1648.  
  1649.     DIR XPL?????.*
  1650.  
  1651. will print information about any file on the task unit whose
  1652. file name begins with the letters "XPL".
  1653.  
  1654. The DIRECTORY command has the ability to accept a switch. The
  1655. letter "L" is used to select between one directory format and
  1656. another. With no switches set, a simplified directory is
  1657. printed. With the "L" switch set, Apex will print out a complete
  1658. directory that includes file name, size, creation date, and the
  1659. area of unit allocated. Thus:
  1660.  
  1661.     DIR 0/L
  1662.  
  1663. The first line of the directory listing prints the system day
  1664. and date (not the date on the disk), the unit number and the
  1665. volume number. The second line contains the title for the
  1666. particular unit. The last line printed describes the free space
  1667. on the unit. FREE prints the total empty space on a unit. MAX
  1668. indicates the largest single free space, which is the largest
  1669. single file the unit can hold at present.
  1670.  
  1671. If the print out of the directory is larger than will fit on the
  1672. screen, the listing will pause at the end of the screen.
  1673. Striking any key will print the rest of the directory.
  1674.  
  1675. DELETE
  1676. 
  1677. This command removes the specified files from the directory. If
  1678. more than one file is to be deleted, fuzzy file names (* and ?)
  1679. can be used.
  1680.  
  1681. When Apex deletes files from the directory, it will list all of
  1682. the files that it is going to remove. It will then ask you to
  1683. verify that these are indeed the files that you wish to remove.
  1684. "Y" will remove the files "N" will leave them. Under some
  1685. circumstances, deleted files can be restored using the backup
  1686. directory described below.
  1687.  
  1688. Example:
  1689.     DELETE 2:FROG.*
  1690.  
  1691. The default extension for delete operations is BAK. This ensures
  1692. that you have to type a little more than just a colon to delete
  1693. the default file.  It also allows the command
  1694.  
  1695.     DELETE *
  1696.  
  1697. to delete any backup files you have on the task unit.
  1698.  
  1699. SAVE
  1700. 
  1701. This command is used to save the contents of memory as an
  1702. executable SAV file. The command takes the name you want it
  1703. saved as, and optionally, a starting and ending address. If the
  1704. starting and ending address is not specified, the command will
  1705. assume that the program area of the system page has the correct
  1706. values in the locations USRMEM and PROSIZ and will take the
  1707. information from them. The first 80 bytes of the system page and
  1708. the area of memory from $0050 through $00FF are automatically
  1709. included in every saved program. Examples:
  1710.  
  1711.     SAVE 2:FROG=$800,$1000
  1712.  
  1713.     SAVE PIG
  1714.  
  1715. The save command requires that Apex be re-enterd at the SAVER
  1716. entry point immediately prior to the SAVE command. In this way
  1717. we can be sure that all of the original memory image will be
  1718. correctly saved, even if part of it was overwritten by the Apex
  1719. Exec.  Apex will take that part of the image to save from the
  1720. file SCRATCH.SYS, where it will have been saved when Apex was
  1721. entered at the SAVER entry.
  1722.  
  1723. If the memory image to be saved was created by a standard Apex
  1724. loader, then the loader will have loaded the data and then
  1725. automatically re-entered Apex through the SAVER entry point. In
  1726. addition, some loaders (the assembly language binary loader is a
  1727. notable exception) will also set up the program size and
  1728. location for you, so that the SAVE command need not have any
  1729. numeric parameters.
  1730.  
  1731. If the memory image was created in some way which leaves you
  1732. talking to a standard Apex program, or to the Apple ROM monitor,
  1733. Control-P or Control-Y repectively, will re-enter Apex at the
  1734. SAVER entry point.
  1735.  
  1736. The SAVE command does not affect any system page paramters other
  1737. than the program location and size. So, unless they were set in
  1738. some other way, you may wish to set the system related
  1739. properties of the program using the SET utility after the SAVE.
  1740.  
  1741. OPEN
  1742. 
  1743. This command opens files for input, output, or both. Files may
  1744. be opened explicitly, or implicitly using the system defaults.
  1745.  
  1746. The OPEN command and a run command funtion in the same way, as
  1747. far as opening files are concerned. The difference is that the
  1748. open command will return immediately to the Apex Exec, while a
  1749. run command executes some other program. Opened files remain
  1750. open until Apex is re-entered or some other files are opened.
  1751.  
  1752. In the general form, the command is followed by two file
  1753. arguments separated by a less-than sign (the "arrow"). The file
  1754. name to the right of the arrow is the input file. The file to
  1755. the left of the arrow is the output file. As in:
  1756.  
  1757.     OPEN OUTPUT<2:INPUT
  1758.  
  1759. Either the input file or the output file can be omitted, and
  1760. Apex will only open the file specified. If a single file name,
  1761. with no arrow, follows the command, the operating system will
  1762. assume that the file is to be both input and output file. For
  1763. example:
  1764.  
  1765. OPEN B.FIL<A.FIL    Opens "A" for input and "B" for output.
  1766.  
  1767. OPEN B.FIL        Opens "B" for both input and output.
  1768.  
  1769. OPEN B.FIL<        Opens "B" for output only.
  1770.  
  1771. OPEN 0:<2:        Opens default file on units as speciifed.
  1772.  
  1773. OPEN <B.FIL        Opens "B" for input only.
  1774.  
  1775. OPEN(SPACE)        Opens the default file on the task unit.
  1776.  
  1777. The OPEN command is usually used only under special circum-
  1778. stances, since files are normally opened in the process of
  1779. executing a SAV file. Any SAV file followed by a file name or
  1780. names will automatically open the specified files. For example:
  1781.  
  1782.     ASM FROG.BIN<FROG.P65
  1783.  
  1784. In some situations, a unit will be so full that not enough space
  1785. will be available for the output file. This is usually handled
  1786. by removing unnecessary files from the unit to make space,
  1787. possibly followed by a SQUASH operation. When the unit is so
  1788. tight that no space can be made by deleting files, the operating
  1789. system allows the output file to be written over the input file.
  1790.  
  1791. This is a dangerous operation and should be used with caution.
  1792. It relies on the fact that the data is buffered in memory
  1793. buffers. Thus, the input file is usually one buffer load ahead
  1794. of the output file. However, if the program adds too much
  1795. information to the output file the output can overwrite the
  1796. input before the input is read. You must also take care to
  1797. ensure that the file doesn't grow to the point that it will no
  1798. longer fit in the free space. The MAKE command can be used to
  1799. prevent this by forcing Apex to make the file too large in the
  1800. first place.
  1801.  
  1802. The overwrite feature is enabled by a /R switch in the command
  1803. line. The switch will operate with both the OPEN command and the
  1804. implied run command. Examples:
  1805.  
  1806.     OPEN FROG.FIL/R
  1807.  
  1808.     EDIT FROG.FIL/R
  1809.  
  1810. INITIALIZE
  1811. 
  1812. This command is used to re-write a copy of Apex on a system
  1813. unit. The SYSTEM.SYS file must already exist on that unit, and
  1814. be 65 blocks long. The file does not need to contain any valid
  1815. information at this point however, and so it could have been
  1816. made by the MAKE command. To write a copy of the currrent Exec
  1817. into the file, you type INIT followed by the unit you wish to
  1818. save it on. The system will write itself onto the new unit in
  1819. the file SYSTEM.SYS. Example:
  1820.  
  1821.     INIT    0
  1822.  
  1823. Note that INIT also saves the system residual area from $A000
  1824. through $AFFF. So if you add handlers in this area you should
  1825. use INIT to make them permanent.
  1826.  
  1827. START
  1828. 
  1829. When a program has been saved in the scratch area of the system
  1830. unit, and has a valid start vector, it can be restarted using
  1831. the START command. Apex keeps track of when it thinks that there
  1832. is a valid program in the scratch area. If the system thinks
  1833. that there is no valid program in the swap area, it will ask you
  1834. to verify the operation. Typing Y will complete the operation, N
  1835. will abort it. If you verify a START when the scratch area or
  1836. start vector is not valid, you can destroy Apex and may have to
  1837. reboot. This command has no arguments or switches.
  1838.  
  1839. SWAP
  1840. 
  1841. This command is similiar to START. SWAP brings the program in
  1842. the swap area into memory but does not execute the program.
  1843. Instead, the ROM monitor is entered. This is useful for patching
  1844. programs before they are saved etc. Apex can be re-entered from
  1845. the ROM monitor with Control-Y. This command has no arguments or
  1846. switches.
  1847.  
  1848. GET
  1849. 
  1850. This command is similiar to a run command. The operating system
  1851. moves a SAV file into memory, but does not begin execution; the
  1852. ROM monitor is entered instead. The command is used mostly to
  1853. change or patch programs. The program can be moved into memory
  1854. using the GET command, then patched, and Apex re-entered with
  1855. Control-Y. The program can then be re-saved using the SAVE
  1856. command. Eg:
  1857.  
  1858.     GET 3:FROG.SAV
  1859.  
  1860. RENAME
  1861. 
  1862. Rename provides a mechanism for changing the name of files.
  1863. Any file name or extension can be changed to any other name or
  1864. extension. The operating system checks to see that renaming the
  1865. file produces no duplicate file conflicts and that the file
  1866. names both refer to the same unit. For example:
  1867.  
  1868.     RENAME NEWFILE<OLDFILE.PIG
  1869.  
  1870.  
  1871. CLOSE
  1872. 
  1873. This command unconditionally closes any open file. The file size
  1874. is left equal to the maximum length of the empty space.
  1875. Generally, files are closed automatically in normal operations.
  1876. This command is only used to recover from situations where the
  1877. program operating on the file has failed to close the file. It
  1878. allows the data that has been sent to the output file to be
  1879. recovered.
  1880.  
  1881. Note that the file will be too long and will probably not
  1882. contain an end-of-file mark (Control-Z). The correct file length
  1883. and end-of-file can usually be restored by editing the file. Use
  1884. the editor to delete the excess data left in the invalid part of
  1885. the file.
  1886.  
  1887. There are no arguments or switches in the close command.
  1888.  
  1889. LIST
  1890. 
  1891. This command allows any ASCII text file to be listed on the
  1892. console  device (Apex device 0). The listing can be interrupted
  1893. with Control-S and aborted with Control-C. Example: 
  1894.  
  1895.     LIST 3:FROG.DAT
  1896.  
  1897. TITLE
  1898. 
  1899. Each unit in Apex can have its own individual title. The title
  1900. is used to keep track of how each unit is being used. The title
  1901. can be up to 32 characters long.
  1902.  
  1903. The TITLE command is used to set or reset the unit title:
  1904.  
  1905.     TITLE  MAILING LISTS
  1906.  
  1907. The command also automatically changes the unit volume number.
  1908. The volume number is derived from the combination of a random
  1909. number and the date. The volume number will be used to prevent
  1910. Apex from writing the wrong directory onto a unit - something
  1911. that could otherwise happen if you changed disks without
  1912. informing Apex with the NEW command.
  1913.  
  1914. To title a unit other than the task unit, you prefix the new
  1915. title with the unit number:
  1916.  
  1917.     TI 4:FOOD FOR THOUGHT
  1918.  
  1919. DFILE
  1920. 
  1921. The DFILE command is used to read or change the system wide file
  1922. default file specification. If DF is typed without an argument,
  1923. the system defaults will be printed. If the command is followed
  1924. by a file name, the system wide file default will be set to this
  1925. file.
  1926.  
  1927. The DF command also prints out the status of the system wide
  1928. switches PACK, BACKUP and CHECK.
  1929.  
  1930. The unit number of the task unit is set by this command and will
  1931. be whatever unit you assigned the default file to. Eg:
  1932.  
  1933.     DFILE 6:NEWFIL.TXT
  1934. or
  1935.     DFILE 3:
  1936. or
  1937.     DFILE    .P65
  1938.  
  1939. NO and DO
  1940. 
  1941. The NO and DO commands are used to set the system wide switches
  1942. PACK, BACKUP and CHECK (pg. 21). DO will turn any of the
  1943. switches on, and NO will turn any of the switches off. For
  1944. example:
  1945.  
  1946.     NO PACK
  1947. or
  1948.     DO BACKUP
  1949.  
  1950. DATE
  1951. 
  1952. Apex maintains a system date which is used to date files as they
  1953. are created. The date is stored in a part of the directory
  1954. on each unit, but only the date on the current system unit is
  1955. used.
  1956.  
  1957. The system date should be updated periodically, using the DATE
  1958. command. When updating the system date, the DATE command must be
  1959. followed by a carriage return. The system will then prompt you
  1960. for a new system date. Example:
  1961.  
  1962.     DATE
  1963.     ENTER NEW DATE: 7-4-79
  1964.  
  1965. The Date is always in the following form: 4-15-79.
  1966.  
  1967. The DATE command can also be used to change the date of a file
  1968. to the current system date. If the DATE command is followed by a
  1969. file name, the file's date will be changed to the current system
  1970. date. Example:
  1971.  
  1972.     DATE 2:FROG.FIL
  1973.  
  1974. BDIR
  1975. 
  1976. The backup directory is a protection feature of the operating
  1977. system. Apex maintains two separate copies of the directory on
  1978. each unit.
  1979.  
  1980. A copy of the main directory is made in the backup directory
  1981. of a unit every time a new output file is opened on that unit.
  1982.  
  1983. If the normal directory is destroyed or if a file is acciden-
  1984. tally erased, the backup directory, if it is recent enough, can
  1985. be used to restore the information.
  1986.  
  1987. The BDIR command reads the backup directory and displays it for
  1988. checking purposes. The command alone only reads the backup
  1989. directory for checking purposes, it does not change the real
  1990. directory.
  1991.  
  1992. A unit number can be appended to the command to refer to a unit
  1993. other than the task unit:
  1994.  
  1995.     BDIR 3
  1996.  
  1997. With the switch /W, the backup directory will be read and
  1998. written back over the normal directory:
  1999.  
  2000.     BDIR/W
  2001.  
  2002. Since the backup directory is only updated when an output file
  2003. is opened on a unit, certain units, such as system units, may
  2004. not normally have a valid backup directory.  The /B switch,
  2005. used with the BDIR command, will force the backup directory
  2006. of a unit to be brought up to date:
  2007.  
  2008.     BDIR 0/B
  2009.  
  2010. SYSTEM
  2011. 
  2012. This command prints the unit number of the current system unit
  2013. or changes the system unit to another unit. The new unit must,
  2014. of course, be a valid system unit. Example:
  2015.  
  2016.     SYSTEM
  2017. or
  2018.     SYSTEM 3
  2019.  
  2020. SIZE
  2021. 
  2022. Apex can deal with units of any size. The size of a unit is
  2023. maintained in its directory. Sometimes a unit may not be
  2024. correctly sized for one reason or another. The Size command
  2025. allows you to check the size of a unit as in:
  2026.  
  2027.     SIZE 2
  2028.  
  2029. Or, it can be used to reset or change the size of a unit as in:
  2030.  
  2031.     SIZE 2=455
  2032.  
  2033. Apple 5.25" floppy disks are normally 455 blocks long while the
  2034. single density 8" disks are normally 1001 blocks long.
  2035.  
  2036. NEW
  2037. 
  2038. This command informs Apex that one or more units have been
  2039. changed. It is effectively equivalent to typing Control-C while
  2040. talking to the Apex Exec.
  2041.  
  2042. Apex does not read unit directories unless it appears necessary.
  2043. This means that it is possible to change the unit in a drive
  2044. without Apex knowing about it. Most often this will just cause a
  2045. bit of confusion.
  2046.  
  2047. Under certain error conditions Apex may try to write the wrong
  2048. directory onto a unit. If so it will detect a volume number
  2049. mismatch and abort the operation.
  2050.  
  2051. However Apex does not do a volume check on every block written,
  2052. only on directory changes. So it is possible to damage
  2053. information on a disk by changing disks at certain critical
  2054. times and neglecting the NEW command.
  2055.  
  2056.         APEX STANDARD UTILITIES
  2057.         =======================
  2058. 
  2059.  
  2060. As described above, any run file can be executed simply by
  2061. typing the file name. In this way, programs can be made at act
  2062. just like commands. Since there are many more desirable
  2063. functions than can be easily incorporated into the operating
  2064. system, it makes sense to make some of the commands run file
  2065. commands. APEX has a number of utilities that are part of the
  2066. standard operating procedures. The user can also create any
  2067. utility to fit his needs.
  2068.  
  2069. If you have a single drive system all these utilities, with the
  2070. exception of COPY and DUPDSK, will still work. However you may
  2071. have to swap disks about somewhat. In general, when a utility
  2072. asks for a unit number on which to perform a function, you must
  2073. make sure the correct disk is in place and, if necessary, change
  2074. the disks **BEFORE** answering the question.
  2075.  
  2076. Here is a description of the standard utility programs:
  2077.  
  2078. SET
  2079. 
  2080. This utility is used to set the program specific portions of the
  2081. system page in a SAV file. It sets the file related defaults as
  2082. well as the memory use parameters. See the section on the system
  2083. page for what these parameters mean.
  2084.  
  2085. SET will present you with each parameter in sequence. If you
  2086. want to change that parameter, enter the new value. If the
  2087. current value is correct, you simply enter a return.
  2088.  
  2089. Since continually SETting a program while debugging is rather
  2090. a tedious process you may wish to include the code to load the
  2091. system page values as a part of the actual program source file.
  2092. However, be clear on what you are loading if you do this, or you
  2093. may upset the loader or its swapping exit process.
  2094.  
  2095. EXCH
  2096. 
  2097. This utility is used to copy files from unit to unit on a single
  2098. drive systems only. It workes only on the system unit. The file
  2099. to be transferred is specified in the run command line as
  2100. usual. EXCHange reads a portion of the original file into memory, the
  2101. disks are exchanged, and the portion is written onto the new
  2102. disk. If the file is large, it may take several exchanges to
  2103. move the entire file. EXCH keeps track of which disk should be
  2104. in the drive, and will prompt you to put the correct disk into
  2105. the drive before each operation.
  2106.  
  2107. When the transfer is complete, it will ask you to put in a
  2108. system unit before it reboots the operating system. Care should
  2109. be taken that the correct disk is in the drive before each
  2110. operation. Placing the wrong disk in the drive can result in the
  2111. destruction of one or more files on that disk.
  2112.  
  2113. SQUASH
  2114. 
  2115. This utility is used to move all active files to the bottom
  2116. portion of the unit. This eliminates any small fragments of
  2117. empty space and creates a single large empty file space.
  2118.  
  2119. COPY
  2120. 
  2121. This utility copies one or more Apex files from one unit to
  2122. another. It requires multiple disk drives. The file name given
  2123. to COPY may be fuzzy if more than one file is to be copied. Copy
  2124. does not currently pick up the file specification from the run
  2125. command line. It requires that the file be separately specified
  2126. in response to the prompt.
  2127.  
  2128. BOOTER
  2129. 
  2130. This utility is used to update the file RESCOD.SYS to include
  2131. some modification to the Apex resident memory area and thus make
  2132. the modification permanent. It will request that you feed it a
  2133. bootable Apex disk as the master. The bootstrap will be taken
  2134. from this disk, while the resident code for Apex will be taken
  2135. from memory.
  2136.  
  2137. MAKER
  2138. 
  2139. This utility is provided to facilitate the process of setting up
  2140. a new Apple 5" mini floppy for use by Apex. The disk in question
  2141. must have been previously formatted with the routine supplied
  2142. with Apex. See the appropriate setion (pg. 7).
  2143.  
  2144. MAKER competely over-writes any previous disk content, and so is
  2145. used only to create valid Apex disks from formatted empty
  2146. disks.
  2147.  
  2148. In the event that you wish to setup a disk other than a standard
  2149. Apple disk, you will have to do the operation "manually". The
  2150. operations which MAKER does for you are equivalent to the
  2151. following steps (in sequence):
  2152.  
  2153.     TITLE the disk.
  2154.     SIZE the disk.
  2155.     ZERO the disk.
  2156.     Set the date.
  2157.     Set the default file.
  2158.     MAKE the file RESCOD.SYS=9,17
  2159.     MAKE the file SCRATCH.SYS=65
  2160.     MAKE the file SYSTEM.SYS=65
  2161.     Use INIT to write the system onto the disk.
  2162.     Use BOOTER to write the resident code onto the disk.
  2163.  
  2164. LOAD
  2165. 
  2166. This program is the standard Apex mechanism for loading the
  2167. binary files produced by the assembler. It will accept a list
  2168. of input files, which will all be loaded in sequence:
  2169.  
  2170.     LOAD FROG,DOG,PIG
  2171.  
  2172. After the load is complete the loader will re-enter Apex at the
  2173. SAVER entry point. You can then use SAVE, SWAP, or START
  2174. commands as decribed earlier.
  2175.  
  2176. Unlike high level language loaders, this loader presets the
  2177. system page parameters to safe values, but does not try to
  2178. divine the "correct" setting for them. You must set them
  2179. yourself, either as a part of the load, or by using the
  2180. appropriate Apex commands and the SET utility.
  2181.  
  2182. The binary loader overlays itself onto the system residual area.
  2183. Thus it cannot be used to load this area directly. It also
  2184. follows that it must force the SYSBOMB flag to TRUE, since the
  2185. Exec is indeed bombed. If the program that was loaded does not
  2186. need this flag TRUE then the flag may be reset to FALSE after
  2187. the program has been made into a SAV file.
  2188.  
  2189. More detail on the loader can be found in the assembler manual.
  2190.  
  2191. DUPDSK
  2192. 
  2193. This simple program can be used to copy entire units from one to
  2194. another. It operates on a block by block basis without any
  2195. reference to content. DUPDSK is used when a unit oriented copy is
  2196. required, such as if you have a mix of different drives, or when
  2197. your units do not correspond to separate disks.
  2198.  
  2199. If you simply want to duplicate an Apple mini-floppy, the Apple
  2200. supplied dual drive disk copy is simpler because it also
  2201. transfers the formatting.
  2202.  
  2203.  
  2204.             COMMAND SUMMARY
  2205.             ===============
  2206. 
  2207.  
  2208. ZERO        Clears directory.
  2209.  
  2210. MAKE        Creates a file.
  2211.  
  2212. DIRECTORY    Prints a directory.
  2213.     /L    Prints the long form of the directory.
  2214.  
  2215. DELETE        Removes specified files from the directory.
  2216.  
  2217. SAVE        Saves specified file from swap area.
  2218.  
  2219. OPEN        Opens specified files for input and/or output.
  2220.     /R    Sets output file to overwrite input file.
  2221.  
  2222. INITIALIZE    Re-writes the operating system on the unit.
  2223.  
  2224. START        Reloads and starts the saved memory image.
  2225.  
  2226. SWAP        Reloads the saved image and enters the monitor.
  2227.  
  2228. GET        Loads a named file and enters the monitor.
  2229.  
  2230. RENAME        Renames a file in the directory.
  2231.  
  2232. CLOSE        Unconditionally closes any open output file.
  2233.  
  2234. LIST        Prints the named file on the console.
  2235.  
  2236. TITLE        Changes the unit title.
  2237.  
  2238. DFILE        Shows or sets the system wide default file name.
  2239.  
  2240. DATE        Changes the system date or a dates a file.
  2241.  
  2242. BDIR        Shows the backup directory of a unit.
  2243.     /W    Overwrites the main directory with backup.
  2244.     /B    Forces a backup directory to be updated.
  2245.  
  2246. DO        Enables the specified system wide switch.
  2247.  
  2248. NO        Disables the specified system wide switch.
  2249.  
  2250. SYSTEM        Shows or changes the system unit number.
  2251.  
  2252. SIZE        Shows or changes the size of a unit.
  2253.  
  2254. NEW        Ensures that Apex knows that you changed disks.
  2255.  
  2256. 
  2257. BOOTER
  2258. 
  2259. This utility is used to update the file RESCOD.SYS to include
  2260. some modification to the Apex resident memory area and th